
********************************
* Manual Made Edits to Dataset *
********************************
*manually deleted first 20 observations from testing
*deleted two rows of question text and tags


**************************
* Dropping Unusable Data *
**************************

*Based on SSI definition of speeders who were dropped
* Q69_Page Submit is Treatment, cut if under 18.4 seconds
* Q70_Page Submit is Control, cut if under 9 seconds
rename q69_pagesubmit vig_durat_treat
rename q70_pagesubmit vig_durat_cont
drop if vig_durat_treat<18.4
drop if vig_durat_cont<9

*drop if distributionchannel=="preview"
** no need to do this, preview responses were already manually dropped

*******************************
* Renaming Basic Demographics *
*******************************

rename q48 consent
rename q7 gender
destring gender, replace
label define genlab 1 "male" 2 "female"
label values gender genlab
rename q9 age
label define agelab 1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65-74" 7 "75 or above"
label values age agelab
rename q11 race
destring race, replace
label define raclab 1 "White" 2 "Black or African American" 3 "Hispanic or Latino" 4 "Asian or Asian American" ///
	5 "Other"
label values race raclab
recode race (1=1)(*=0), gen(white)
gen nonwhite= (white==0)
rename q65 state
label define statelab 1 "Alabama" 2 "Alaska" 3 "Arizona" 4 "Arkansas" 5 "California" 6 "Colorado" 7 "Connecticut" ///
	8 "Delaware" 9 "District of Columbia" 10 "Florida" 11 "Georgia" 12 "Hawaii" 13 "Idaho" 14 "Illinois" 15 "Indiana" ///
	16 "Iowa" 17 "Kansas" 18 "Kentucky" 19 "Louisiana" 20 "Maine" 21 "Maryland" 22 "Massachusetts" 23 "Michigan" ///
	24 "Minnesota" 25 "Mississippi" 26 "Missouri" 27 "Montana" 28 "Nebraska" 29 "Nevada" 30 "New Hampshire" 31 "New Jersey" ///
	32 "New Mexico" 33 "New York" 34 "North Carolina" 35 "North Dakota" 36 "Ohio" 37 "Oklahoma" 38 "Oregon" 39 "Pennsylvania" ///
	40 "Puerto Rico" 41 "Rhode Island" 42 "South Carolina" 43 "South Dakota" 44 "Tennessee" 45 "Texas" 46 "Utah" 47 "Vermont" ///
	48 "Virginia" 49 "Washington" 50 "West Virginia" 51 "Wisconsin" 52 "Wyoming" 53 "Not in US"
		* added this but code below isn't recognizing state name
label values state statelab
rename q13 pid1				/* pid1 identifies PID from initial branching, 4 point scale including other */
rename q13_4_text pidoth
rename q15 demstr
rename q17 gopstr 
rename q19 indlean 


********************
** Quotas         **
********************
**Region
gen region_ne=0
gen region_mw=0
gen region_so=0
gen region_we=0
foreach i in ne mw so we{
replace region_`i'=. if state==. | state==53
}
replace region_ne=1 if (state==7) | (state==20) | (state==22) | (state==30) | (state==41) | (state==47) | (state==31) | (state==33) | (state==39)
replace region_mw=1 if (state==14) |(state==15) |(state==23) |(state==36) |(state==51) |(state==16) |(state==17) |(state==24) |(state==26) |(state==28) |(state==35) |(state==43) 
replace region_so=1 if (state==9) | (state==8) | (state==10) | (state==11) | (state==21) | (state==34) | (state==42) | (state==48) | (state==50) | (state==1) | (state==18) | (state==25) | (state==44) | (state==4) | (state==19) | (state==37) | (state==45) 
replace region_we=1 if (state==3) | (state==6) | (state==13) | (state==27) | (state==29) | (state==32) | (state==46) | (state==52) | (state==2) | (state==5) | (state==12) | (state==38)  | (state==49)

tab state region_ne
tab state region_mw
tab state region_so
tab state region_we

gen region= (region_ne==1)
replace region=2 if region_mw==1
replace region=3 if region_so==1
replace region=4 if region_we==1
label define regilab 1 "ne" 2 "mw" 3 "so" 4 "we"
label values region regilab

**State number should match names below
*replace region_ne=1 if (statelab=="Connecticut") | (statelab=="Maine") | (statelab=="Massachusetts") | (statelab=="New Hampshire") | (statelab=="Rhode Island") | (statelab=="Vermont") | (statelab=="New Jersey") | (statelab=="New York") | (statelab=="Pennsylvania")
*replace region_mw=1 if (statelab=="Illinois") |(statelab=="Indiana") |(statelab=="Michigan") |(statelab=="Ohio") |(statelab=="Wisconsin") |(statelab=="Iowa") |(statelab=="Kansas") |(statelab=="Minnesota") |(statelab=="Missouri") |(statelab=="Nebraska") |(statelab=="North Dakota") |(statelab=="South Dakota") 
*replace region_so=1 if (statelab=="District of Columbia") | (statelab=="Delaware") | (statelab=="Florida") | (statelab=="Georgia") | (statelab=="Maryland") | (statelab=="North Carolina") | (statelab=="South Carolina") | (statelab=="Virginia") | (statelab=="West Virginia") | (statelab=="Alabama") | (statelab=="Kentucky") | (statelab=="Mississippi") | (statelab=="Tennessee") | (statelab=="Arkansas") | (statelab=="Louisiana") | (statelab=="Oklahoma") | (statelab=="Texas") 
*replace region_we=1 if (statelab=="Arizona") | (statelab=="Colorado") | (statelab=="Idaho") | (statelab=="Montana") | (statelab=="Nevada") | (statelab=="New Mexico") | (statelab=="Utah") | (statelab=="Wyoming") | (statelab=="Alaska") | (statelab=="California") | (statelab=="Hawaii") | (statelab=="Oregon")  | (statelab=="Washington")

**Quotas by region
tab region_ne //17% (aiming for 16%)
tab region_mw //22.51% (aiming for 23%)
tab region_so //38.71% (aiming for 37%)
tab region_we //21.78% (aiming for 24%)

**Gender
tab gender // 47.88% male, 52.12% female (aiming for 49% male, 51% female)

**race
tab race //69.19% white, 13.2% Black, 11.95% Hispanic, 4.71% Asian, .93% Other 

**age
tab age //12.02% 18-24, 20.39% 25-34, 20.32% 35-44, 17.07% 45-54, 16.00% 55-64, 11.62% 65-74, 2.59% 75 +
**Aiming for 
**18-24=17%
**25-34=17% 
*35-44=18% 
*45-54=18%
*55-64=14%
*65+= 14%

********************
** PID Indicators **
********************

recode pid1 (4=3)(5=3), gen(pid1to3)
label define pid1to3lab 1 "Democrat" 2 "Republican" 3 "independent/other/not sure"
label values pid1to3 pid1to3lab
gen ispartisan= (pid1==1) | (pid1==2)

recode pid1to3 (1=-2)(2=2) (3=0), gen(pid7)
replace pid7=-3 if demstr==1
replace pid7=3 if gopstr==1
replace pid7=-1 if indlean==1
replace pid7=1 if indlean==2
label define pid7lab -3 "Strong Dem" -2 "Weak Dem" -1 "Lean Dem" 0 "Indep/Not Sure" 1 "Lean Repub" 2 "Weak Repub" 3 "Strong Repub"
label values pid7 pid7lab  /* pid7 identifies PID from full branching, 7 point scale */

gen isparorlean= (pid7>=-3 & pid7<=-1) | (pid7<=3 & pid7>=1)
gen isstrongpar= (pid7==-3) | (pid7==3)
gen isweakpar= (pid7==-2) | (pid7==2)
gen islean= (pid7==-1) | (pid7==1)
gen isindep= (pid7>=-1 & pid7<=1)
gen ispureind= (pid7==0)

gen strongdem= (pid7==-3)
gen weakdem= (pid7==-2)
gen weakgop= (pid7==2)
gen stronggop= (pid7==3)

gen pid3=pid7
replace pid3=1 if pid7<0  /* pid3 identifies PID from full branching, 3 point scale */
replace pid3=2 if pid7>0 & pid7<=4
replace pid3=3 if pid7==0
label define pid3lab 1 "Dem or Lean Dem" 3 "True Indep" 2 "Rep or Lean Rep"
label values pid3 pid3lab /* does not include "not sure" */

gen pidstrength=isstrongpar
replace pidstrength=2 if isweakpar==1
replace pidstrength=3 if islean==1
label define fullpstrenglab 1 "Strong Partisan" 2 "Weak Partisan" 3 "Leaner" 0 "Pure Indep"
label values pidstrength fullpstrenglab

gen isdem= (pid3==1)
gen isgop= (pid3==2)
gen demvgop=isdem
replace demvgop=2 if isgop==1
recode demvgop (0=.)
gen isdemorlean= (pid3==1)
gen isgoporlean= (pid3==2)

***********************************
** Ideology, Interest, Educ, etc **
***********************************
rename q21 ideo7
recode ideo7 (1=-1)(2=-.66667)(3=-.33333)(4=0)(5=.33333)(6=.66667)(7=1)(8=.), gen(ideology)  /* here, "not sure" is recoded as missing */  
label define persideo -1 "very liberal" 0 "moderate" 1 "very conservative"
label values ideology persideo
recode ideology (-1=1)(-.66667=.66667)(-.33333=.33333), gen(absideo)
label define absideolab 0 "neither lib nor cons" 1 "very lib or cons"
label values absideo absideolab
gen ismod= (ideology==0)
label define modlab 1 "ID not lib/cons" 0 "ID lib/cons"
label values ismod modlab

rename q23 interest
	*scale 1 very interested to 5 not at all interested
recode interest (1=1)(2=.75)(3=.5)(4=.25)(5=0), gen(polint)
rename q25 educ

*********************
* Outcome Variables *
*********************
recode q53 (1=0)(2=.25)(3=.5)(4=.75)(5=1), gen(o_cong)
label define conglab 0 "None" 1 "A great deal"
label values o_cong conglab
recode q57 (1=0)(2=.166667)(3=.33333)(4=.5)(5=.66667)(6=.83333)(7=1), gen(o_bill) 
label define billab 0 "Strongly oppose it" 1 "Strongly suppport it"
label values o_bill billab

rename q68_2 o_warm_maj
gen o_warm_maj_01 = (o_warm_maj/100)
rename q69_2 o_warm_min
gen o_warm_min_01 = (o_warm_min/100)


************************
* Treatment Conditions *
************************
label define majlab 1 "DemMaj" 2 "GOPMaj"
label values maj majlab
label define altlab 1 "bipartisan" 2 "minority"
label values alt altlab
label define pollab 1 "jury maj" 2 "sent maj"
label values policy pollab
rename q71 manip_chk
label define maniplab 1 "Republican party" 2 "Democratic party" 3 "wasn't specified"
label values manip_chk maniplab
gen manip_correct= (maj==1 & manip_chk==2) | (maj==2 & manip_chk==1)
tab control, sum(manip_correct)
	* 62% correct in treatment, 47% correct in control
gen ownmaj= (maj==1 & isdem==1) | (maj==2 & isgop==1)
gen oppmaj= (maj==1 & isgop==1) | (maj==2 & isdem==1)
gen majrel=ownmaj
recode majrel (0=.)
replace majrel=2 if (maj==1 & isgop==1) | (maj==2 & isdem==1)
label define mrel 1 "own maj" 2 "opp maj"
label values majrel mrel
gen fulltreat=1 if ownmaj==1 & control==1
replace fulltreat=3 if alt==1 & control==0 & ownmaj==1
replace fulltreat=5 if alt==2 & control==0 & ownmaj==1
replace fulltreat=2 if oppmaj==1 & control==1
replace fulltreat=4 if alt==1 & control==0 & oppmaj==1
replace fulltreat=6 if alt==2 & control==0 & oppmaj==1
replace fulltreat=7 if pid3==3
label define fulltreatlab 1 "own cont" 2 "opp cont" 3 "ownvbip" 4 "oppvbip" 5 "ownvopp" 6 "oppvown" 7 "pure indep"
label values fulltreat fulltreatlab

**generate new variable for treatment regressions
gen full_treatment = .
replace full_treatment = 0 if control==1 
replace full_treatment = 1 if control==0 & alt2=="bipartisan support among members"
replace full_treatment = 2 if control==0 & alt2!="bipartisan support among members"
sum full_treatment
label define full_tlab 0 "control" 1 "bipartisan" 2 "minority"
label values full_treatment full_tlab

**compare to other variable
tab full_treatment fulltreat


********************
* Issue Importance *
********************
rename q35_1 i_crim
rename q35_2 i_spend
rename q35_3 i_immig
rename q35_4 i_ener
rename q35_5 i_clim
rename q35_6 i_hc
rename q35_7 i_tax


**************************
**  Political knowledge **
**************************
rename q36 no_outsideknow
rename q37 k_mueller
rename q38 k_freecauc
rename q39 k_brexit
rename q41 k_gorsuch
rename q42 k_secstate
rename q69 income

**Political knowledge index
gen k_mueller_correct = 0
replace k_mueller_correct=1 if k_mueller==4
gen k_freecauc_correct = 0
replace k_freecauc_correct=1 if k_freecauc==3
gen k_brexit_correct = 0
replace k_brexit_correct=1 if k_brexit==4
gen k_gorsuch_correct = 0
replace k_gorsuch_correct=1 if k_gorsuch==1
gen k_secstate_correct = 0
replace k_secstate_correct=1 if k_secstate==3 //Note that he was fired toward the end of our fielding period
**sum correct
gen k_correct_sum = k_mueller_correct + k_freecauc_correct + k_brexit_correct + k_gorsuch_correct + k_secstate_correct
sum k_correct_sum
**Indicator for those in top half of knowledge (by median)
egen k_correct_sum_median = median(k_correct_sum)
gen k_correct_sum_tophalf = 0
replace k_correct_sum_tophalf=1 if k_correct_sum >= k_correct_sum_median


rename v95 whystudy
rename v96 comments
rename v97 ssisurveys
* had multiple q37, q39, and q41 - that's why these are auto-renamed v
label define ssilab 1 "none" 2 "1 to 2" 3 "3 to 5" 4 "6 to 9" 5 "10 or more"
label values ssisurveys ssilab
